Files
pf-linux-port/module/include/compat/net/ifq.h
T
lgcosta 1fcd7b3046 M1 progress: engine port compiles except pf.c; AF_DIVERT socket family; ifq framework
- compat layer extended through the full BSD API surface pf_ioctl/pf_lb/
  pf_if/pf_norm/pf_table/pf_ruleset/radix/md5/sha2 need (all compile):
  cpumem/counters model, ifaddr/ifg groups, cred view, endian+in6 names,
  NAT46/64, SipHash24, mbuf_list, frag6 helpers, ip6 forward/checksum,
  tcp options/FSM names, taskqueue & sysctl shims (documented in
  docs/porting-notes.md)
- pfsrc/divert_sock.c: real BSD divert(4) as runtime-registered PF_DIVERT=32
  socket family inside the module (sock_register; NPROTO=AF_MAX=45 -> zero
  core patches); divert_packet/divert6_packet wired for pf.c
- compat/pfk_ifq.c: OpenBSD 8.0 ifq framework with priq back end; hfsc and
  fq_codel aliases pending M5 (recorded in feature matrix as pending)
- design + plan updated for the divert decision (user-requested)
- stage-port.sh: single deterministic rename program for headers and .c
2026-11-11 13:35:53 -03:00

108 lines
3.1 KiB
C

/* PFLINUX compat: <net/ifq.h> — OpenBSD 8.0 transmit-queue framework.
* Field names follow upstream (ifqop_*) so the ported PF code stays
* line-proximate. The framework itself is implemented in compat/pfk_ifq.c
* (priq semantics); the HFSC and fq_codel back ends are ported in
* milestone M5 and plug into the same ops structures.
*/
#ifndef _PFK_IFQ_H
#define _PFK_IFQ_H
#include <linux/types.h>
/* struct pfq_ops comes from net/pfvar.h (OpenBSD 8.0) — it is included by
* pfk.h before this header. */
struct mbuf;
struct mbuf_list;
struct ifnet;
struct pfk_ifnet;
struct pf_queuespec;
#define IFQ_MAXLEN 256
struct ifqueue {
struct pfk_ifnet *ifq_if;
void *ifq_softc;
const struct ifq_ops *ifq_ops;
void *ifq_q;
struct mbuf_list *ifq_free; /* free list (unused in the port) */
unsigned int ifq_len;
unsigned int ifq_oactive;
/* statistics */
u_int64_t ifq_packets;
u_int64_t ifq_bytes;
u_int64_t ifq_qdrops;
u_int64_t ifq_errors;
u_int64_t ifq_mcasts;
u_int32_t ifq_oactives;
void *ifq_kstat;
/* properties */
unsigned int ifq_maxlen;
unsigned int ifq_idx;
};
struct ifq_ops {
unsigned int (*ifqop_idx)(unsigned int, const struct mbuf *);
struct mbuf *(*ifqop_enq)(struct ifqueue *, struct mbuf *);
struct mbuf *(*ifqop_deq_begin)(struct ifqueue *, void **);
void (*ifqop_deq_commit)(struct ifqueue *, struct mbuf *,
void *);
void (*ifqop_purge)(struct ifqueue *, struct mbuf_list *);
void *(*ifqop_alloc)(unsigned int, void *);
void (*ifqop_free)(unsigned int, void *);
};
extern const struct ifq_ops * const ifq_priq_ops;
extern const struct ifq_ops * const ifq_hfsc_ops;
extern const struct ifq_ops * const ifq_fqcodel_ops;
extern const struct pfq_ops * const pfq_hfsc_ops;
extern const struct pfq_ops * const pfq_fqcodel_ops;
void ifq_init(struct ifqueue *, struct ifnet *, unsigned int);
void ifq_init_maxlen(struct ifqueue *, unsigned int);
void ifq_attach(struct ifqueue *, const struct ifq_ops *, void *);
void ifq_destroy(struct ifqueue *);
int ifq_enqueue(struct ifqueue *, struct mbuf *);
void ifq_start(struct ifqueue *);
struct mbuf *ifq_deq_begin(struct ifqueue *);
void ifq_deq_commit(struct ifqueue *, struct mbuf *);
void ifq_deq_rollback(struct ifqueue *, struct mbuf *);
struct mbuf *ifq_dequeue(struct ifqueue *);
unsigned int ifq_purge(struct ifqueue *);
void ifq_mfreem(struct ifqueue *, struct mbuf *);
void ifq_mfreeml(struct ifqueue *, struct mbuf_list *);
void ifq_set_oactive(struct ifqueue *);
void ifq_deq_set_oactive(struct ifqueue *);
int ifq_hdatalen(struct ifqueue *);
#define ifq_len(_ifq) READ_ONCE((_ifq)->ifq_len)
#define ifq_empty(_ifq) (ifq_len(_ifq) == 0)
static inline int
ifq_is_priq(struct ifqueue *ifq)
{
return (ifq->ifq_ops == ifq_priq_ops);
}
static inline void
ifq_clr_oactive(struct ifqueue *ifq)
{
ifq->ifq_oactive = 0;
}
static inline unsigned int
ifq_is_oactive(struct ifqueue *ifq)
{
return (ifq->ifq_oactive);
}
static inline unsigned int
ifq_idx(struct ifqueue *ifq, unsigned int nifqs, const struct mbuf *m)
{
return ((*ifq->ifq_ops->ifqop_idx)(nifqs, m));
}
#endif