packet->rcv_flags = 0;
 }
 
-#ifndef CONFIG_PRESCAN_RXQ
-static void prescan_rxq(struct hfi1_packet *packet) {}
-#else /* !CONFIG_PRESCAN_RXQ */
-static int prescan_receive_queue;
-
 static void process_ecn(struct rvt_qp *qp, struct hfi1_ib_header *hdr,
                        struct hfi1_other_headers *ohdr,
                        u64 rhf, u32 bth1, struct ib_grh *grh)
  * containing Excplicit Congestion Notifications (FECNs, or BECNs).
  * When an ECN is found, process the Congestion Notification, and toggle
  * it off.
+ * This is declared as a macro to allow quick checking of the port to avoid
+ * the overhead of a function call if not enabled.
  */
-static void prescan_rxq(struct hfi1_packet *packet)
+#define prescan_rxq(rcd, packet) \
+       do { \
+               if (rcd->ppd->cc_prescan) \
+                       __prescan_rxq(packet); \
+       } while (0)
+static void __prescan_rxq(struct hfi1_packet *packet)
 {
        struct hfi1_ctxtdata *rcd = packet->rcd;
        struct ps_mdata mdata;
 
-       if (!prescan_receive_queue)
-               return;
-
        init_ps_mdata(&mdata, packet);
 
        while (1) {
                update_ps_mdata(&mdata, rcd);
        }
 }
-#endif /* CONFIG_PRESCAN_RXQ */
 
 static inline int skip_rcv_packet(struct hfi1_packet *packet, int thread)
 {
                goto bail;
        }
 
-       prescan_rxq(&packet);
+       prescan_rxq(rcd, &packet);
 
        while (last == RCV_PKT_OK) {
                last = process_rcv_packet(&packet, thread);
        }
        smp_rmb();  /* prevent speculative reads of dma'ed hdrq */
 
-       prescan_rxq(&packet);
+       prescan_rxq(rcd, &packet);
 
        while (last == RCV_PKT_OK) {
                last = process_rcv_packet(&packet, thread);
                }
        }
 
-       prescan_rxq(&packet);
+       prescan_rxq(rcd, &packet);
 
        while (last == RCV_PKT_OK) {
 
 
        /* nothing to do since memory is freed by hfi1_free_devdata() */
 }
 
-static struct kobj_type port_cc_ktype = {
-       .release = port_release,
-};
-
 static struct bin_attribute cc_table_bin_attr = {
        .attr = {.name = "cc_table_bin", .mode = 0444},
        .read = read_cc_table_bin,
        .size = PAGE_SIZE,
 };
 
+struct hfi1_port_attr {
+       struct attribute attr;
+       ssize_t (*show)(struct hfi1_pportdata *, char *);
+       ssize_t (*store)(struct hfi1_pportdata *, const char *, size_t);
+};
+
+static ssize_t cc_prescan_show(struct hfi1_pportdata *ppd, char *buf)
+{
+       return sprintf(buf, "%s\n", ppd->cc_prescan ? "on" : "off");
+}
+
+static ssize_t cc_prescan_store(struct hfi1_pportdata *ppd, const char *buf,
+                               size_t count)
+{
+       if (!memcmp(buf, "on", 2))
+               ppd->cc_prescan = true;
+       else if (!memcmp(buf, "off", 3))
+               ppd->cc_prescan = false;
+
+       return count;
+}
+
+static struct hfi1_port_attr cc_prescan_attr =
+               __ATTR(cc_prescan, 0600, cc_prescan_show, cc_prescan_store);
+
+static ssize_t cc_attr_show(struct kobject *kobj, struct attribute *attr,
+                           char *buf)
+{
+       struct hfi1_port_attr *port_attr =
+               container_of(attr, struct hfi1_port_attr, attr);
+       struct hfi1_pportdata *ppd =
+               container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
+
+       return port_attr->show(ppd, buf);
+}
+
+static ssize_t cc_attr_store(struct kobject *kobj, struct attribute *attr,
+                            const char *buf, size_t count)
+{
+       struct hfi1_port_attr *port_attr =
+               container_of(attr, struct hfi1_port_attr, attr);
+       struct hfi1_pportdata *ppd =
+               container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
+
+       return port_attr->store(ppd, buf, count);
+}
+
+static const struct sysfs_ops port_cc_sysfs_ops = {
+       .show = cc_attr_show,
+       .store = cc_attr_store
+};
+
+static struct attribute *port_cc_default_attributes[] = {
+       &cc_prescan_attr.attr
+};
+
+static struct kobj_type port_cc_ktype = {
+       .release = port_release,
+       .sysfs_ops = &port_cc_sysfs_ops,
+       .default_attrs = port_cc_default_attributes
+};
+
 /* Start sc2vl */
 #define HFI1_SC2VL_ATTR(N)                                 \
        static struct hfi1_sc2vl_attr hfi1_sc2vl_attr_##N = { \